class Territory{
    constructor() {}
    static getInstance(){
        if(!Territory.instance) {
            Territory.instance = new Territory();
        }
        return Territory.instance;
    }

    /**
     * 移除所有多边形的点
     * @param data
     */
    removeALLTerritory(data) {
        OBJECT.routerEdgePoints=[];
    }

    /**
     * 生成Territory
     * @param data
     */
    createTerritory( data )
    {
        this.removeALLTerritory();
        Polygon.deleteAllPloygon();
        data.forEach( function ( value ,index) {

                 let routerId = getRandomRouterId();
                 OBJECT.routerEdgePoints[routerId] = value.router_edge_points;
                 OBJECT.routerPonits[routerId]=[];
                 OBJECT.routerPonits[routerId].points = value.routers;
                 OBJECT.routerPonits[routerId].vehicleId = value.vehicle_id;
                 OBJECT.routerPonits[routerId].driverId = value.driver_id;
                 OBJECT.routerPonits[routerId].schedule = value.schedule;
                 OBJECT.routerPonits[routerId].UpdateStatus = false;
                 CONFIG.optimizeOrderpoints[routerId] = false;
                 OBJECT.routersNameMap[routerId] = value.title;
                 OBJECT.routersBgColorMap[routerId] = getRandomColor();
                 Queue(routerId)
        },this);
    }
}